Converts an array of LeadPointD from one coordinates to the other.
public virtual void ConvertPoints(
ImageViewerItem item,
ImageViewerCoordinateType fromType,
ImageViewerCoordinateType toType,
LeadPointD[] points
)
public:
virtual void ConvertPoints(
ImageViewerItem^ item,
ImageViewerCoordinateType^ fromType,
ImageViewerCoordinateType^ toType,
array<LeadPointD^>^ points
)
item
The reference item. This value can be null.
fromType
Original coordinates of points.
toType
Desired target coordinates.
points
Array of points to convert.
Use ConvertPoint to convert a single point and ConvertPoints to convert an array of points at once. The viewer needs to create temporary matrices for the conversion, so if you have multiple points, convert them all at once for optimal performance.
Use ConvertRect to convert a rectangle.
The values of item, fromType and toType controls how the point is converted as described below. If the conversion uses an item and the value of item is null, then the viewer will use ActiveItem to support point conversion in a single-view mode.
fromType | toType | item |
Description |
---|---|---|---|
Not used |
Converts a point from control coordinates such as a mouse event in relation to the view |
||
Not used |
Converts a point from view coordinates to control. The reverse of the previous operation |
||
Used |
Converts a point from control coordinates such as a mouse event in relation to the whole of the item |
||
Used |
Converts a point from item to control. The reverse of the previous operation |
||
Used |
Converts a point from control coordinates such as a mouse event in relation to the content area of the item |
||
Used |
Converts a point from content to control. The reverse of the previous operation |
||
Used |
Converts a point from control coordinates such as a mouse event in relation to the image of the item |
||
Used |
Converts a point from image to control. The reverse of the previous operation |
||
Used |
Converts a point from control coordinates such as a mouse event in relation to the floater image of the item |
||
Used |
Converts a point from image floater to control. The reverse of the previous operation |
For more information refer to Image Viewer Layouts, Image Viewer Appearance, Image Viewer Items, Image Viewer Transformation, and Image Viewer Bounds and Transform.
using Leadtools;
using Leadtools.Controls;
using Leadtools.Codecs;
using Leadtools.Drawing;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
public ImageViewerForm _form = new ImageViewerForm();
public ImageViewer _imageViewer;
public void ImageViewerItemTransformExample()
{
// Get the Form's ImageViewer control
_imageViewer = _form.ImageViewer;
// Load an image
using (var codecs = new RasterCodecs())
_imageViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"));
int dy = 1;
LeadPoint position = LeadPoint.Create(0, 0);
double total = _imageViewer.GetItemViewBounds(_imageViewer.ActiveItem, ImageViewerItemPart.Item, false).Height;
double factor;
LeadPointD[] points = new LeadPointD[2];
points[0] = LeadPointD.Create(position.X, position.Y);
points[1] = LeadPointD.Create(position.X * .5, position.Y * .5);
LeadRect rect = new LeadRect(position.X, position.Y, _imageViewer.Height, _imageViewer.Width);
if (total > 0)
factor = 1.0 - (dy * 2.0) / total;
else
factor = 1.0;
// Get the origin in image coordinate
var origin = _imageViewer.ConvertPoint(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, position).ToLeadPointD();
// Convert it to whatever the current transform is
origin = _imageViewer.ActiveItem.Transform.Transform(origin);
Debug.WriteLine(origin.X.ToString() + " " + origin.Y.ToString());
_imageViewer.ConvertPoints(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, points);
_imageViewer.ConvertRect(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, rect);
_imageViewer.GetItemContentTransform(_imageViewer.ActiveItem);
_imageViewer.GetItemImageTransform(_imageViewer.ActiveItem);
_imageViewer.GetItemTransform(_imageViewer.ActiveItem);
Debug.WriteLine(_imageViewer.ImageTransform);
var transform = LeadMatrix.Identity;
transform.ScaleAt(1 / factor, 1 / factor, origin.X, origin.Y);
_imageViewer.ActiveItem.Transform = LeadMatrix.Multiply(_imageViewer.ActiveItem.Transform, transform);
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document